<?php

/***  DOCUMENTATION LAYER

Last Update: Mar 2007
	
DESCRIPTION
	Testing array search to determine best way to verify host server
	
NOTES
	
***/

// Timer
$_tx0 = microtime();

// HEADER
echo "<h1 style='margin:8px 0 0;'>CEO Sandbox</h1>";
echo "<h4 style='margin:0 0 16px;'>Host Server Verification</h4>";	// put script name here

// *** PROCEDURAL
if ( 1 ) 
{
	echo "<h4 style='margin:0; color:blue;'>Testing Array Search</h4>";
  $ARRAY = array
  (
    'local' => 'foo1',
    'local' => 'foo2',
    'alpha' => 'foo3',
    'alpha' => 'foo4',
    'beta' => 'foo5',    
  );
  
  $ARRAY2 = array
  (
    array( 'local', 'foo1' ),
    array( 'local', 'foo2' ),
    array( 'alpha', 'foo3' ),
    array( 'beta', 'foo4' ),
  );
  
  // search array 1
  $full_array = print_r($ARRAY, 1);
  $foo1 = array_search('foo1', $ARRAY);
  $foo2 = array_search('foo2', $ARRAY);
  $foo5 = array_search('foo5', $ARRAY);
  
  // search for foo2 in array2
  $full_array2 = print_r($ARRAY2, 1);
  $foo1_is_found = 0;
  $foo1_is = '';
  foreach ( $ARRAY2 as $_SRV )
  {
    if ( $_SRV[1] == 'foo1' )
    {
      $foo1_is_found = 1;
      $foo1_is = $_SRV[0];
      break;
    }
  }
  
  $result = <<<HTML
  
<pre>  
Array Search Test 2

looking for paired value for 'foo1' (should be 'local')
is found: $foo1_is_found
value: $foo1_is

$full_array2




Array Search Test 1

array_search(ARRAY, 'foo1') = $foo1
array_search(ARRAY, 'foo2') = $foo2
array_search(ARRAY, 'foo5') = $foo5

$full_array
</pre>
  
HTML;

  echo $result;
}



// *** FUNCTION
/*____________________________________________________________________________*/
function name() 
{
// *** DATA

	// Return


// *** MANIPULATE

// *** RETURN

} 
/*____________________________________________________________________________*/


// Test Function
if ( 0 )
{
	$run = 10;
	echo "<h2 style='margin:0; color:green;'>Function Test</h2>";	
	while ( $run )
	{
		// $result = function();
		echo "<h6 style='margin:0; color:#ccc;'>test #{$run} complete</h6>";
		$run--;
	}
}

// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
$footer = <<<HTML
<h4 style="margin:0; position:absolute; top:6px; right:6px; font-family:monospace; color:#36f; padding:4px; border:1px solid #36f; font-weight:normal; background:#f3f6ff;">
script completed in $stx s
</h4>
HTML;
echo $footer;

?>
